package oocl.eshop.util.jms;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.jdom.Document;
import oocl.eshop.po.Merchant;

public class JmsReceXML {
	public static Document doc;
	public static Merchant merchant = null;
	public static String sMerchant = null;

	public static void jmsReceXML() {
		ConnectionFactory factory = new ActiveMQConnectionFactory("failover://tcp://10.222.232.167:61616");
		Destination queue = new ActiveMQQueue("storeXML");
		Connection con;
		Session sen;
		MessageConsumer consumer;
		// TextMessage message;
		try {
			con = factory.createConnection();
			con.start();
			sen = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
			consumer = sen.createConsumer(queue);
			
			// 匿名内部类不断接收xml文件			
			consumer.setMessageListener(new DoMessageListener());
 

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

